package com.example.exceldemo.controller;

import com.example.exceldemo.service.PdfService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.io.IOException;

/**
 * @Description
 * @Author xiaohuang
 * @Date 2024/9/9
 */
@RequestMapping("pdf")
@Api(tags = "pdf导出")
@RestController
public class PdfController {
    @Resource
    private PdfService pdfService;
    @GetMapping("exportTemplate")
    @ApiOperation(value = "pdf模板导出(itextpdf)", produces = "application/octet-stream")
    public void exportTemplate() throws IOException {
        pdfService.exportTemplate();
    }

    @ApiOperation(value = "自定义pdf导出-表格遍历(itextpdf)", produces = "application/octet-stream")
    @GetMapping("/exportPdf")
    public void exportPdf() {
        pdfService.exportPdf();
    }
    @ApiOperation(value = "docx转pdf(docx4j)", produces = "application/octet-stream")
    @GetMapping("/exportWordToPdf")
    public void exportWordToPdf() {
        pdfService.exportWordToPdf();
    }
    @ApiOperation(value = "html转pdf(openpdf)", produces = "application/octet-stream")
    @GetMapping("/exportHtmlToPdf")
    public void exportHtmlToPdf() {
        pdfService.exportHtmlToPdf();
    }
    @ApiOperation(value = "自定义导出-表格遍历(itextpdf)", produces = "application/octet-stream")
    @GetMapping("/initExportPdf")
    public void initExportPdf() {
        pdfService.initExportPdf();
    }
}
